<script type="text/javascript">
	jQuery(document).ready(function($) {
		$('#filtros select').change(function(){
			var url = $(this).val();
			if (url) { window.location = url; }
			return false;
		})
	});
</script>
<?php 
	$o = (isset($_GET['o'])) ? $_GET['o'] : '';	
?>
<div id="filtros" style="margin:0;">
	<?
	$args = array(
		'authors'      => '',
		'child_of'     => 9,
		'date_format'  => get_option('date_format'),
		'depth'        => 0,
		'echo'         => 1,
		'exclude'      => '',
		'include'      => '',
		'link_after'   => '',
		'link_before'  => '',
		'post_type'    => 'page',
		'post_status'  => 'publish',
		'show_date'    => '',
		'sort_column'  => 'menu_order, post_title',
		'title_li'     => __('Pages'), 
		'walker'       => '',
		'order'        => 'ASC',
		'orderby'      => 'title',
		'nopaging'     => true,							
	);
	query_posts($args);
	$paises = array();
	while ( have_posts() ) : the_post(); 
		$array = get_post_custom_values('origem');
		$pais_de_origem = $array[0];
		if (!in_array($pais_de_origem, $paises) && $pais_de_origem != '') {
			$paises[] = $pais_de_origem;
		}
	endwhile; // end of the loop.
	wp_reset_query();
	?>
	<select name="origem" id="">
		<option value="<?=get_bloginfo('wpurl');?>/fornecedores" selected="selected">ORIGEM</option>
		<?php
		$origem = get_post_custom_values('origem');
		$selected = $origem[0];
		foreach ($paises as $pais) {
			$selected = ($o == $pais) ? 'selected="selected"' : '';
			$option = '<option value="'.get_bloginfo('wpurl' ).'/fornecedores/?o='.$pais.'" '.$selected. '>';
			$option .= $pais;
			$option .= '</option>';
			echo $option;
		}
		?>
	</select>	
</div>